<template>
	<view class="report-container">
		<view class="title">
			<h1 id="tit0">婚恋风险报告</h1>
			<h4 class="tit1">姓名：{{name}}</h4>

			<h4 class="tit1">单号：{{orderNo}}</h4>
			<h4 class="tit1">有效时间至：{{endTime}}</h4>
		</view>

		<view style="margin-top: 20px">
			<h4 class="bgtitle">报告摘要</h4>
			<table border>
				<tr>
					<th>调查项目</th>
					<th>是否完成</th>
					<th>调查结果</th>
				</tr>
				<tr>
					<td>身份核实</td>
					<td>{{sfhy}}</td>
					<td>
						<uni-icons class="sm" :type="dcjgSfhs?'checkmarkempty':'closeempty'" size="15"
							:color="dcjgSfhs?'green':'red'" />
					</td>
				</tr>
				<tr>
					<td>婚姻信息</td>
					<td>{{isHyjl?'已完成':'未完成'}}</td>
					<td><uni-icons class="sm" :type="isHyjl?'checkmarkempty':'closeempty'" size="15"
							:color="isHyjl?'green':'red'" /></td>
				</tr>
				<tr>
					<td>法院公告</td>
					<td>{{grss}}</td>
					<td><uni-icons class="sm" :type="fyggs.length>0?'closeempty':'checkmarkempty'" size="15"
							:color="fyggs.length>0?'red':'green'" /></td>
				</tr>
				<tr>
					<td>涉案信息</td>
					<td>{{grss}}</td>
					<td><uni-icons class="sm" :type="saxxs.length>0?'closeempty':'checkmarkempty'" size="15"
							:color="saxxs.length>0?'red':'green'" /></td>
				</tr>
				<tr>
					<td>案件流程</td>
					<td>{{grss}}</td>
					<td><uni-icons class="sm" :type="ajlcs.length>0?'closeempty':'checkmarkempty'" size="15"
							:color="ajlcs.length>0?'red':'green'" /></td>
				</tr>
				<tr>
					<td>曝光台</td>
					<td>{{grss}}</td>
					<td><uni-icons class="sm" :type="bgts.length>0?'closeempty':'checkmarkempty'" size="15"
							:color="bgts.length>0?'red':'green'" /></td>
				</tr>
				<tr>
					<td>执行公告</td>
					<td>{{grss}}</td>
					<td><uni-icons class="sm" :type="zxggs.length>0?'closeempty':'checkmarkempty'" size="15"
							:color="zxggs.length>0?'red':'green'" /></td>
				</tr>
			</table>
			<view>
				<h4>结果说明</h4>
				<view>
					<uni-icons class="sm" type="checkmarkempty" size="15" color="green"></uni-icons>代表查询结果属实或无负面风险信息
				</view>
				<view>
					<uni-icons class="sm" type="closeempty" size="15" color="red"></uni-icons>代表查询结果存在较大差异或负面风险信息
				</view>
			</view>
		</view>

		<view class="bgitem">
			<h4 class="bgtitle">报告正文</h4>
			<table border>
				<tr>
					<th colspan="4">身份核实</th>
				</tr>
				<tr>
					<td>身份证号</td>
					<td>{{cardNo}}</td>
					<td>姓名</td>
					<td>{{name}}</td>
				</tr>

				<tr>
					<td>性别</td>
					<td>{{getSex(cardNo)}}</td>
					<td>年龄</td>
					<td>{{getAge(cardNo)}}</td>
				</tr>

				<tr>
					<td>身份核验结果</td>
					<td>{{hyjg}}</td>
					<td>出生日期</td>
					<td>{{getBirth(cardNo)}}</td>
				</tr>
			</table>
		</view>

		<view class="bgitem">
			<table border>
				<tr>
					<th colspan="2">婚姻信息</th>
				</tr>
				<tr>
					<td>查询结果</td>
					<td>{{hyxx}}</td>
				</tr>
			</table>
		</view>

		<view class="bgitem">
			<table border>
				<tr>
					<th colspan="2">法院公告</th>
				</tr>
				<tr>
					<td>查询结果</td>
					<td>截止本报告之日前，有{{fyggs.length}}条匹配信息</td>
				</tr>
				<tr>
					<td colspan="2"></td>
				</tr>
				<template v-for="(item, index) in fyggs">
					<tr>
						<td>案号</td>
						<td>
							{{ item.c_ah }}
						</td>
					</tr>
					<tr>
						<td>案件类型</td>
						<td>
							{{ item.n_ajlx }}
						</td>
					</tr>
					<tr>
						<td>法院</td>
						<td>
							{{ item.n_jbfy }}
						</td>
					</tr>
					<tr>
						<td>诉讼身份</td>
						<td>
							{{ item.n_ssdw }}
						</td>
					</tr>
					<tr>
						<td>立案时间</td>
						<td>
							{{ item.d_larq  }}
						</td>
					</tr>
					<tr>
						<td>结案时间</td>
						<td>
							{{ item.d_jarq}}
						</td>
					</tr>
					<tr>
						<td>结案方式</td>
						<td>
							{{ item.c_ah }}
						</td>
					</tr>
					<tr>
						<td>执行标的金额</td>
						<td>
							{{ item.n_sqzxbdje }}
						</td>
					</tr>
					<tr>
						<td>判决结果</td>
						<td>
							{{ item.n_jafs}}
						</td>
					</tr>
					<tr>
						<td colspan="2">第{{index+1}}条 / 共{{fyggs.length}}条</td>
					</tr>

				</template>
			</table>
		</view>

		<view class="bgitem">
			<table border>
				<tr>
					<th colspan="2">涉案信息</th>
				</tr>
				<tr>
					<td>查询结果</td>
					<td>截止本报告之日前，有{{saxxs.length}}条匹配信息</td>
				</tr>
				<tr>
					<td colspan="2"></td>
				</tr>
				<template v-for="(item, index) in saxxs">
					<tr>
						<td>案号</td>
						<td>
							{{ item.c_ah }}
						</td>
					</tr>
					<tr>
						<td>案件类型</td>
						<td>
							{{ item.n_ajlx }}
						</td>
					</tr>
					<tr>
						<td>法院</td>
						<td>
							{{ item.n_jbfy }}
						</td>
					</tr>
					<tr>
						<td>诉讼身份</td>
						<td>
							{{ item.n_ssdw }}
						</td>
					</tr>
					<tr>
						<td>立案时间</td>
						<td>
							{{ item.d_larq  }}
						</td>
					</tr>
					<tr>
						<td>结案时间</td>
						<td>
							{{ item.d_jarq}}
						</td>
					</tr>
					<tr>
						<td>结案方式</td>
						<td>
							{{ item.c_ah }}
						</td>
					</tr>
					<tr>
						<td>执行标的金额</td>
						<td>
							{{ item.n_sqzxbdje }}
						</td>
					</tr>
					<tr>
						<td>判决结果</td>
						<td>
							{{ item.n_jafs}}
						</td>
					</tr>
					<tr>
						<td colspan="2">第{{index+1}}条 / 共{{saxxs.length}}条</td>
					</tr>
				</template>
			</table>
		</view>

		<view class="bgitem">
			<table border>
				<tr>
					<th colspan="2">案件流程</th>
				</tr>
				<tr>
					<td>查询结果</td>
					<td>截止本报告之日前，有{{ajlcs.length}}条匹配信息</td>
				</tr>

				<tr>
					<td colspan="2"></td>
				</tr>
				<template v-for="(item, index) in ajlcs">
					<tr>
						<td>案号</td>
						<td>
							{{ item.c_ah }}
						</td>
					</tr>
					<tr>
						<td>案件类型</td>
						<td>
							{{ item.n_ajlx }}
						</td>
					</tr>
					<tr>
						<td>法院</td>
						<td>
							{{ item.n_jbfy }}
						</td>
					</tr>
					<tr>
						<td>诉讼身份</td>
						<td>
							{{ item.n_ssdw }}
						</td>
					</tr>
					<tr>
						<td>立案时间</td>
						<td>
							{{ item.d_larq  }}
						</td>
					</tr>
					<tr>
						<td>结案时间</td>
						<td>
							{{ item.d_jarq}}
						</td>
					</tr>
					<tr>
						<td>结案方式</td>
						<td>
							{{ item.c_ah }}
						</td>
					</tr>
					<tr>
						<td>执行标的金额</td>
						<td>
							{{ item.n_sqzxbdje }}
						</td>
					</tr>
					<tr>
						<td>判决结果</td>
						<td>
							{{ item.n_jafs}}
						</td>
					</tr>
					<tr>
						<td colspan="2">第{{index+1}}条 / 共{{ajlcs.length}}条</td>
					</tr>
				</template>

			</table>
		</view>

		<view class="bgitem">
			<table border>
				<tr>
					<th colspan="2">曝光台</th>
				</tr>
				<tr>
					<td>查询结果</td>
					<td>截止本报告之日前，有{{bgts.length}}条匹配信息</td>
				</tr>

				<template v-for="(item, index) in bgts">
					<tr>
						<td>案号</td>
						<td>
							{{ item.c_ah }}
						</td>
					</tr>
					<tr>
						<td>案件类型</td>
						<td>
							{{ item.n_ajlx }}
						</td>
					</tr>
					<tr>
						<td>法院</td>
						<td>
							{{ item.n_jbfy }}
						</td>
					</tr>
					<tr>
						<td>诉讼身份</td>
						<td>
							{{ item.n_ssdw }}
						</td>
					</tr>
					<tr>
						<td>立案时间</td>
						<td>
							{{ item.d_larq  }}
						</td>
					</tr>
					<tr>
						<td>结案时间</td>
						<td>
							{{ item.d_jarq}}
						</td>
					</tr>
					<tr>
						<td>结案方式</td>
						<td>
							{{ item.c_ah }}
						</td>
					</tr>
					<tr>
						<td>执行标的金额</td>
						<td>
							{{ item.n_sqzxbdje }}
						</td>
					</tr>
					<tr>
						<td>判决结果</td>
						<td>
							{{ item.n_jafs}}
						</td>
					</tr>
					<tr>
						<td colspan="2">第{{index+1}}条 / 共{{bgts.length}}条</td>
					</tr>
				</template>
			</table>
		</view>

		<view class="bgitem">
			<table border>
				<tr>
					<th colspan="2">执行公告</th>
				</tr>
				<tr>
					<td>查询结果</td>
					<td>截止本报告之日前，有{{zxggs.length}}条匹配信息</td>
				</tr>

				<template v-for="(item, index) in zxggs">
					<tr>
						<td>案号</td>
						<td>
							{{ item.c_ah }}
						</td>
					</tr>
					<tr>
						<td>案件类型</td>
						<td>
							{{ item.n_ajlx }}
						</td>
					</tr>
					<tr>
						<td>法院</td>
						<td>
							{{ item.n_jbfy }}
						</td>
					</tr>
					<tr>
						<td>诉讼身份</td>
						<td>
							{{ item.n_ssdw }}
						</td>
					</tr>
					<tr>
						<td>立案时间</td>
						<td>
							{{ item.d_larq  }}
						</td>
					</tr>
					<tr>
						<td>结案时间</td>
						<td>
							{{ item.d_jarq}}
						</td>
					</tr>
					<tr>
						<td>结案方式</td>
						<td>
							{{ item.c_ah }}
						</td>
					</tr>
					<tr>
						<td>执行标的金额</td>
						<td>
							{{ item.n_sqzxbdje }}
						</td>
					</tr>
					<tr>
						<td>判决结果</td>
						<td>
							{{ item.n_jafs}}
						</td>
					</tr>
					<tr>
						<td colspan="2">第{{index+1}}条 / 共{{zxggs.length}}条</td>
					</tr>
				</template>

			</table>
		</view>

		<view class="bgitem">
			<hr>
			<p style="text-align: center;margin: 15px;">报告摘要</p>
			<p style="font-size: 12px;line-height: 22px;">基于被调查人授权及提供的个人资料，通过专业调查流程，由火微科技提供以上报告。火微科技竭力确保其
				提供之数据准确可靠，但不保证该等数据绝对正确可靠；对于任何因资料不确或遗漏又或因根据或倚赖本报
				告资料所作决定、行动或不行动、以及收集与传递过程中的偏差而引致之损失或损害，火微科技背调概不负
				责（不论是民事侵权行为责任或合约责任或其它）。本报告仅作为入职聘用方面参考，不得用于其他用途。
				任何机构或个人不得以任何形式复制、转发或公开传播本报告的全部或部分内容，不得将报告内容作为诉讼
				、仲裁、传媒所引用之证明或依据，不得用于营利或用于未经允许的其它用途。根据本报告信息作出的任何
				商业行为，该行为后果由行为人自行负责。</p>
		</view>
		<template v-if="lock">
			<liu-drag-button @clickBtn="FX()">分享</liu-drag-button>
		</template>
	</view>
</template>
<script>
	import {
		concealKeyword,
		query
	} from '@/api/jinjian.js'

	import {
		marTemInfo
	} from '@/utils/temInfo.js'

	export default {
		name: "mar",
		data() {
			return {
				lock: false,
				name: '',
				orderNo: 'TEM001',
				endTime: '',

				sfhy: '未完成',
				dcjgSfhs: true,

				isHyjl: false,

				grss: '未完成',
				cardNo: '',

				hyjg: '',

				hyxx: '',

				fyggs: [],
				saxxs: [],
				ajlcs: [],
				bgts: [],
				zxggs: []
			}
		},
		onLoad(options) {
			console.log('--options--', options)
			if (options.code) {
				this.orderNo = (options.orderNo ? options.orderNo.substring(0, options.orderNo.indexOf('-')) : '')
				if (options.code != 0) {
					let userId
					concealKeyword(this.orderNo).then(res => {
						userId = res.userId
					})
					let this_ = this
					uni.showModal({
						title: '人脸核验本人未通过',
						content: '是否重新核验？',
						cancelText: '取消',
						confirmText: '确定',
						success: function(res) {
							if (res.confirm) {
								this_.$tab.reLaunch('/pages/check?orderNo=' + this_.orderNo);
							} else if (res.cancel) {
								this_.$tab.reLaunch('/pages/marriage?ui=' + userId);
							}
						}
					})
					return
				} else {
					this.$modal.loading('正在查询，请稍后...')
					query(this.orderNo).then(res => {
						console.log(res)
						if (res.code === 200) {
							this.hanbleData(res.data)
						} else {
							this.$modal.alert(res.msg)
						}
					})
				}
			} else if (options.orderNo) {
				this.orderNo = options.orderNo
				this.$modal.loading('正在查询，请稍后...')
				query(this.orderNo).then(res => {
					console.log(res)
					if (res.code === 200) {
						this.hanbleData(res.data)
					} else {
						this.$modal.alert(res.msg)
					}
				})
			} else {
				this.hanbleData(marTemInfo)
			}
		},
		methods: {
			hanbleData(data) {
				this.name = data.name
				this.endTime = data.endTime
				this.cardNo = data.cardNo


				const smrz = data.smrz
				if (smrz.retcode == '000000') {
					this.sfhy = '已完成'
					if (smrz.retdata.final_valid_result == '0') {
						this.hyjg = '姓名，身份证号一致'
					} else {
						this.hyjg = smrz.retmsg
						dxjgSfhs = false
					}
				} else if (smrz.retcode == '4005') {
					this.$modal.msgLoading(smrz.retmsg)
				}

				const hyhy = data.hyhy
				if (hyhy.retcode == '000000') {
					this.isHyjl = true
					this.hyxx = hyhy.retdata.messge
				} else if (hyhy.retcode == '4005') {
					this.$modal.msgLoading(hyhy.retmsg)
				}

				const grss = data.grss
				if (grss.retcode == '000000') {
					this.grss = '已完成'
					const retdata = grss.retdata
					if (retdata.resultCode == 1) {
						var detail1 = retdata.detail[0]
						this.fyggs = 'cases' in detail1.civil ? detail1.civil.cases : []
						this.saxxs = 'cases' in detail1.criminal ? detail1.criminal.cases : []
						this.ajlcs = 'cases' in detail1.administrative ? detail1.administrative.cases : []
						this.bgts = 'cases' in detail1.preservation ? detail1.preservation.cases : []
						this.zxggs = 'cases' in detail1.implement ? detail1.implement.cases : []
					}
				} else if (grss.retcode == '4005') {
					this.$modal.msgLoading(grss.retmsg)
				}
				this.lock = true
				this.$modal.closeLoading()
			},
			getBirth(UUserCard) {
				const birth =
					UUserCard.substring(6, 10) + "-" +
					UUserCard.substring(10, 12) + "-" +
					UUserCard.substring(12, 14)
				return birth
			},
			getSex(UUserCard) {
				return parseInt(UUserCard.substr(16, 1)) % 2 === 1 ? '男' : '女'
			},
			getAge(UUserCard) {
				const myDate = new Date()
				const month = myDate.getMonth() + 1
				const day = myDate.getDate()
				const age = myDate.getFullYear() - UUserCard.substring(6, 10);
				// let age = myDate.getFullYear() - UUserCard.substring(6, 10) - 1;
				// if (UUserCard.substring(10, 12) < month || (UUserCard.substring(10, 12) === month && UUserCard.substring(12, 14) <= day)) {
				//   age++;
				// }
				return age
			}
		}
	}
</script>
<style scoped lang="scss">
	.report-container {
		min-height: 100vh;
		background: url("@/static/images/bg.png") no-repeat 0 0, #F5F6FC;
		background-size: contain;
		padding: 35px 15.0px;
		box-sizing: border-box;

		.title {
			width: 100%;
			color: antiquewhite;
			text-align: center;

			#tit0 {
				margin-bottom: 40px;
			}

			.tit1 {
				margin-bottom: 10px;
			}
		}

		.bgitem {
			margin-top: 50px;
		}

		.bgtitle {
			text-align: center;
			margin-bottom: 10px
		}

		table {
			width: 100%;
			border-collapse: collapse;
			border-color: #94949C;
		}

		th {
			padding: 8px 0;
			// background-color: #46b5ff;
			// color: #fafafa;
			text-align: center;
		}

		td {
			padding: 6px 0;
			text-align: center;
		}

		.sm {
			margin: 10px;
			line-height: 30px;
		}
	}
</style>